<?php

    //8/29/2009: immanuel192 rewrite this code
    // Feb 11, 2011 -trungdt -- Add remove html in body mode
    // Sept 3, 2012 - add Our Team

    if (!defined('EXPONENT')) exit('');

    $link = null;
    $config=null;
    if (isset($_GET['id'])) {
        $link = $db->selectObject('linklist_link','id='.$_GET['id']);
        $config=null;
        if ($link) {
            $loc = unserialize($link->location_data);
        }
    }
    $config = $db->selectObject('linklistmodule_config',"location_data='".serialize($loc)."'");
    if ($config == null) {
        $config->orderby = 'name';
        $config->orderhow = 0; // Ascending
        $config->remove_body_html=0;
        $config->name_multiline=0;
        $config->listing_type=0;
    }

    if (($link && exponent_permissions_check('edit',$loc)) || (!$link && exponent_permissions_check('create',$loc))) {
        // call the right one of form builder
        if ($config->listing_type == 0)
            $form = linklist_link::form($link,$config);
        else
        if ($config->listing_type == 1) // Our team
            $form = linklist_ourteam::form($link,$config);
            
        $form->location($loc);
        $form->meta('action','save');

        $template = new template('linklistmodule','_form_edit');
        $template->assign('is_edit',(isset($link->id)? 1 : 0));
        $template->assign('config',$config);
        $template->assign('form_html',$form->toHTML());
        $template->output();
        exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC","top_loginmodule_".LANG);
    exponent_sessions_set("AB_THEME_TOP_CONTAINER_TYPE","textmodule");
    } else {
        exponent_http_error(403);
    }

?>